package edu.bu.grocerylist.model;

import java.io.Serializable;

/**
 * This class represents the individual shopping item within a GroceryList
 * @author donlanp
 *
 */
public class GroceryListItem implements Serializable, Comparable<GroceryListItem>{
	

	private static final long serialVersionUID = 6971574072620168946L;
	
	public final static String NOT_SHOPPED = "notshopped";
	public final static String SHOPPED = "shopped";
	
	private int listId;
	
	private int itemId;
	private String name;
	
	private int categoryId;
	private String category;
	private String categoryDescription;
	
	private int quantity;
	private String measurement;
	
	private String status = NOT_SHOPPED;
	
	private boolean shopped;
	

	/**
	 * @return the itemId
	 */
	public int getItemId() {
		return itemId;
	}

	/**
	 * @param itemId the itemId to set
	 */
	public void setItemId(int itemId) {
		this.itemId = itemId;
	}

	/**
	 * @return the listId
	 */
	public int getListId() {
		return listId;
	}
	
	/**
	 * Primarily used for debugging
	 */
    public String toString() {
    	String item = "----------------------";
    	item += "Item ID: " + this.itemId + "\n";
    	item += "List ID: " + this.listId + "\n";
    	item += "Item Name: " + this.name + "\n";
    	item += "Item Category: " + this.category + "\n";
    	item += "Item Quantity/Unit: " + this.quantity + " " + this.measurement + "\n";
    	item += "----------------------";
    	return item;
    }
	/**
	 * @param listId the listId to set
	 */
	public void setListId(int listId) {
		this.listId = listId;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the category
	 */
	public String getCategory() {
		return category;
	}

	/**
	 * @param category the category to set
	 */
	public void setCategory(String category) {
		this.category = category;
	}

	/**
	 * @return the categoryDescription
	 */
	public String getCategoryDescription() {
		return categoryDescription;
	}

	/**
	 * @param categoryDescription the categoryDescription to set
	 */
	public void setCategoryDescription(String categoryDescription) {
		this.categoryDescription = categoryDescription;
	}

	/**
	 * @return the quantity
	 */
	public int getQuantity() {
		return quantity;
	}

	/**
	 * @param quantity the quantity to set
	 */
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	/**
	 * @return the measurement
	 */
	public String getMeasurement() {
		return measurement;
	}

	/**
	 * @param measurement the measurement to set
	 */
	public void setMeasurement(String measurement) {
		this.measurement = measurement;
	}

	/**
	 * @return the status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	/**
	 * @return the categoryId
	 */
	public int getCategoryId() {
		return categoryId;
	}

	/**
	 * @param categoryId the categoryId to set
	 */
	public void setCategoryId(int categoryId) {
		this.categoryId = categoryId;
	}

	/**
	 * @return the shopped
	 */
	public boolean getShopped() {
		return shopped;
	}

	/**
	 * @param shopped the shopped to set
	 */
	public void setShopped(boolean shopped) {
		this.shopped = shopped;
	}

	/**
	 * Adding method to automatically sort by category
	 */
	public int compareTo(GroceryListItem o) {
		if(category != null){
			return this.category.compareTo(o.getCategory());			
		}
		
		return -1;
	}
	
	

}
